package com.zuihai.app.mvp.ui.activity.home;

import android.os.Bundle;
import android.view.View;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.zuihai.app.mvp.constant.DetailConstant;
import com.zuihai.app.mvp.model.entity.HomeItem;
import com.zuihai.app.mvp.ui.activity.detail.DetailContainerActivity;

import java.util.Calendar;

/**
 * Created by Zc on 2017/5/3.
 * 首页-热点
 */

public class ArticleFragment extends HomeRecyclerFragment {
    private String type="";
    public static ArticleFragment newInstance(String type) {

        Bundle args = new Bundle();
        args.putString("type", type);
        ArticleFragment fragment = new ArticleFragment();
        fragment.setArguments(args);
        return fragment;
    }

    @Override
    protected void initData() {
        super.initData();
        type=getArguments().getString("type");
    }

    @Override
    protected void requestData(boolean isRefresh) {
        mPresenter.getActicle(isRefresh,type);
    }

    @Override
    public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
        long currentTime = Calendar.getInstance().getTimeInMillis();
        if (currentTime - lastClickTime > MIN_CLICK_DELAY_TIME) {
            lastClickTime = currentTime;
            HomeItem item = (HomeItem) adapter.getItem(position);
            String detailId = item.id;
            DetailContainerActivity.launchActivity(getContext(),
                    DetailConstant.HEADLINE_TYPE,type, detailId);
        }
    }
}
